﻿using System;
using System.Linq.Expressions;
using System.Reflection;

namespace Columbus
{
    public static class ViewStateExtensions
    {
        public static string GetViewStateKey<T>(this Expression<Func<T>> propertySelector)
        {
            return propertySelector.GetMember().GetViewStateKey();
        }

        public static string GetViewStateKey(this MemberInfo property)
        {
            if (property == null) throw new ArgumentNullException("property");
            return String.Format("{0}.{1}", property.DeclaringType.FullName, property.Name);
        }
    }
}